package aa;

import java.awt.image.BufferedImage;

import com.attilax.img.imgx;
import com.attilax.io.filexEx;
import com.jhlabs.image.ContrastFilter;
import com.jhlabs.image.GammaFilter;
import com.jhlabs.image.GrayscaleFilter;
import com.jhlabs.image.HSBAdjustFilter;
import com.jhlabs.image.RGBAdjustFilter;
import com.jhlabs.image.SharpenFilter;

public class enhan2 {
	public static void main(String[] args) {
		String f = "D:\\000图像增强样图\\1.jpg";
		BufferedImage img = imgx.toImg(f);
		ContrastFilter flt = new ContrastFilter();
		RGBAdjustFilter hsvFlt = new RGBAdjustFilter();
		float contrast = 2.3f;
		contrast = 1.3f;
		flt.setContrast(contrast);
		float brightness = 0.91f;
		flt.setBrightness(brightness);
		BufferedImage gray_copy = flt.filter(img, null);
		imgx.save_overwrite(gray_copy, filexEx.addTimestampNSuffix(f, "contras" + contrast + " brt" + brightness));

		// ------------clr enhance
		HSBAdjustFilter hsbFlt = new HSBAdjustFilter();
		float sFactor = 0.08f;
		hsbFlt.setSFactor(sFactor);
		hsbFlt.setBFactor(0.2f);
		BufferedImage color_enhs = hsbFlt.filter(gray_copy, null);
		imgx.save_overwrite(color_enhs,
				filexEx.addTimestampNSuffix(f, "contras" + contrast + " brt" + brightness + " color_enhs" + sFactor));
		
		int gamma = 2;
		BufferedImage gammaed = new GammaFilter(gamma).filter(color_enhs, null);
		imgx.save_overwrite(gammaed,
				filexEx.addTimestampNSuffix(f, "gammaed"+gamma));
		
		BufferedImage sharped=new  SharpenFilter().filter(gammaed, null);
		imgx.save_overwrite(sharped,
				filexEx.addTimestampNSuffix(f, "sharped"));
		System.out.println("--f");
	}

}
